<?php

/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Url;
use backend\assets\AdminAsset;
use yii\helpers\Html;
use backend\components\Menu;
AdminAsset::register($this);

?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>控制台 - Bootstrap后台管理系统模版Ace下载</title>		
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- basic styles -->
        <?php $this->head() ?>
        <?php
        AdminAsset::addScript($this,'@web/js/jquery.treetable.js');
        AdminAsset::addCss($this,'@web/css/jquery.treeview.css');
        AdminAsset::addCss($this,'@web/css/jquery.treeTable.css');
        $this->registerJsFile("@web/js/jquery-2.1.4.js",['position' =>\yii\web\View::POS_HEAD]);?>

	</head>
    <body>
    <?php $this->beginBody() ?>
    <div class="container-fluid">
<div class="row">
    <div class="col-sm-4">
        <table class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th>选择站点</th>
                </tr>
            </thead>
            <?php foreach($sites as $site){?>
            <tbody>
                <tr>
                    <td><a href="<?=Url::toRoute(['role/rolepriv', 'roleid' => $_GET['roleid'],'siteid'=>$site->siteid])?>"><?php echo $site->name;?></a></td>
                </tr>
            </tbody>
            <?php }?>
        </table>
    </div>
    <div class="col-sm-8">
        <table  class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th>权限设置</th>
                </tr>
            </thead>
        </table>
        <form name="myform"  method="post">
            <input type="hidden" name="<?php echo Yii::$app->request->csrfParam;?>" value="<?php echo Yii::$app->request->getCsrfToken();?>"> 
            <table id="dnd-example" cellspacing="0" class="table table-striped table-bordered table-hover">
                <tbody>
                <?php echo $categorys;?>
                </tbody>
            </table>
            <input type="submit" name="submit" value="提交"></input>
        </form>
    </div><!-- /.table-responsive -->
</div><!-- /.row end -->

    </div>
<?php $this->beginBlock('check') ?>  
$(document).ready(function() {
    $("#dnd-example").treeTable({
    	indent: 20
    	});
  });
function checknode(obj)
{
    var chk = $("input[type='checkbox']");
    var count = chk.length;
    
    var num = chk.index(obj);
    
    var level_top = level_bottom =  chk.eq(num).attr('level');
    //alert($(obj).prop('checked'));
    for (var i=num; i>=0; i--)
    {
            var le = chk.eq(i).attr('level');
            
            if(eval(le) < eval(level_top)) 
            {
                chk.eq(i).prop("checked",'checked');
                var level_top = level_top-1;
            }
            
    }
    for (var j=num+1; j<count; j++)
    {
            var le = chk.eq(j).attr('level');

            
            if(chk.eq(num).prop("checked")==true) {
                if(eval(le) > eval(level_bottom)) chk.eq(j).prop("checked",'checked');
                else if(eval(le) == eval(level_bottom)) break;
            }
            else {
               
                if(eval(le) > eval(level_bottom)) chk.eq(j).prop("checked",'');
                else if(eval(le) == eval(level_bottom)) break;
            }
    }
}
<?php $this->endBlock() ?>  
<?php $this->registerJs($this->blocks['check'], \yii\web\View::POS_END); ?> 
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>